home *** CD-ROM | disk | FTP | other *** search
- /*
- * rnews.c - uux command for bootstrap news
- * copyright 1989 Ronald Florence (ron@mlfarm 7/9/89)
- *
- * Modified (a lot) for use with MT C-Shell by David Beckemeyer
- * (david@bdt 8/23/89)
- *
- */
-
- #include <stdio.h>
- #include <time.h>
-
- #define MAILER "\\usr\\bin\\rmail.prg"
- #define USER "netnews"
-
- #ifndef Newsspool
- #define Newsspool "\\usr\\spool\\news\\bsnews"
- #endif
- #ifndef Feeder
- #define Feeder "Usenet"
- #endif
-
- extern char **environ;
-
- extern char *feedhost();
-
- main()
- {
- FILE *nf, *cf;
- char buf[BUFSIZ];
- register c;
- int new = 1, n;
-
- while (fgets(buf, BUFSIZ, stdin) != NULL)
- {
- /* batched? */
- if (!strncmp(buf, "#! ", 3))
- {
- /* compressed? */
- if (!strncmp(buf+3, "cunbatch", 8))
- {
- fprintf(stderr, "cannot handle compressed batches yet\n");
- exit(1);
- }
- /* unpack the batch */
- else if (sscanf(buf+3, "rnews %d", &n) == 1)
- {
- if (!(nf = fopen(Newsspool, "w")))
- {
- fprintf(stderr, "rnews: can't write to %s\n", Newsspool);
- exit(1);
- }
-
- timestamp(nf);
- for (c = 0; c < n; c += strlen(buf))
- {
- fgets(buf, BUFSIZ, stdin);
- if (!strncmp(buf, "From ", 5))
- putc('>', nf);
- fputs(buf, nf);
- }
- putc('\n', nf);
- fclose(nf);
- sendmail();
- continue;
- }
- }
- /* it must be unbatched */
- else
- {
- if (new)
- {
- if (!(nf = fopen(Newsspool, "w")))
- {
- fprintf(stderr, "rnews: can't write to %s\n", Newsspool);
- exit(1);
- }
- timestamp(nf);
- new = 0;
- }
- if (!strncmp(buf, "From ", 5))
- putc('>', nf);
- fputs(buf, nf);
- }
- }
- if (!new) {
- putc('\n', nf);
- fclose(nf);
- sendmail();
- }
- exit(0);
- }
-
- static char *mailargv[] = {
- "rmail",
- Newsspool,
- USER,
- 0
- };
-
- sendmail()
- {
- execve(MAILER, mailargv, environ);
- }
-
- timestamp(newsfile)
- FILE *newsfile;
- {
- long clock;
- char *ctime();
- char *p, cb[32];
-
- time(&clock);
- strcpy(cb, ctime(&clock));
- cb[strlen(cb)-1] = 0;
- fprintf(newsfile, "From %s %s remote from %s\n\n", Feeder, cb, feedhost());
- }
-